package org.iabako.shared.iservice.business;

import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.AsyncCallback;
import org.iabako.shared.entity.business.CustomField;
import org.iabako.shared.entity.business.CustomFieldListItem;
import org.iabako.shared.entity.business.CustomFieldValue;

import java.util.List;
import java.util.Map;

/**
 * Created by jose on 22/09/14.
 */
public interface CustomFieldServiceAsync {

    void getCustomFieldsListItemValues(CustomField customField, AsyncCallback<List<CustomFieldListItem>> async);

    void getCustomFields(AsyncCallback<List<CustomField>> async);

    void saveCustomFields(List<CustomField> fields,
                          Map<CustomField, List<String>> customFieldListItemTextAdded,
                          Map<CustomField, List<String>> customFieldListItemTextDeleted, AsyncCallback<Void> async);

    void getUsagesCustomField(CustomField customField, AsyncCallback<Long> async);

    void getUsagesCustomFieldListValue(CustomField customField, String itemText, AsyncCallback<Long> async);

    void getCustomCriteriaSearchFields(AsyncCallback<List<CustomFieldValue>> asyncCallback);

    public static final class Util {
        private static CustomFieldServiceAsync instance;

        public static final CustomFieldServiceAsync getInstance() {
            if (instance == null) {
                instance = GWT.create(CustomFieldService.class);
            }
            return instance;
        }
    }
}
